// export default {
//     canUndo: true,
//     execute: (context, options, isUndo) => {
//         const { sheet, row, rowCount = 1, old,table } = options;
        
//         try {
//             sheet.suspendPaint();
//             if (isUndo) {
//                 sheet.deleteRows(row, rowCount);
//             } else {
//                 console.log(rowCount,table.range().colCount);
//                 const {rowCount:r ,colCount}= table.range();

//                 sheet.tables.resize(table,r + rowCount,colCount);
//             }
//             sheet.resumePaint();
//         } catch (e) {
//             if (!!(window.console && window.console.log)) {
//                 window.console.log(e);
//             }
//         }
//     }
// };
export default {
    canUndo: true,
    execute: (context, options, isUndo) => {
        try {
            const { sheet, row: addRow, rowCount: addRowCount = 1, table,type } = options;
            sheet.suspendPaint();
            const { row: dataRow } = table.dataRange();
            if (isUndo) {
                
                const { name, row, col, rowCount, colCount, columns, cellTypes, bindingPath, showHeader, addRow} = options.old;
                sheet.deleteRows(addRow,1);
                sheet.tables.resize(table,rowCount, colCount);
            } else {
                const { row, col, name, rowCount, colCount, columns, bindingPath,showHeader, } = table.toJSON();
                options.old = {
                    name, row, col, rowCount, colCount, columns, bindingPath,showHeader,addRow
                    
                };
                sheet.addRows(addRow,addRowCount);
                let num = -1;
                if(type=='top') {
                    num = 1;
                }
                sheet.setRowHeight(addRow, sheet.getRowHeight(addRow + num))
                sheet.tables.resize(table,rowCount+addRowCount, colCount);
            }
            sheet.resumePaint();
        } catch (e) {
            if (!!(window.console && window.console.log)) {
                window.console.log(e);
            }
        }
    }
};